import javax.media.opengl.awt.GLCanvas;


public class Model {
	public int lightSettings;
	public int renderSettings;
	public double angle;
	public boolean freeze;
	public GLCanvas view;
	
	public Model(){
		this.lightSettings = 0;
		this.renderSettings = 0;
		this.angle = 0;
		this.freeze = false;
	}
	
	public void setView(GLCanvas view){
		this.view = view;
	}
	
	public void switchLight(){
		switch (lightSettings) {
		  case 0: 
			lightSettings = 1;
		    break;
		  case 1: 
			lightSettings = 2;
		    break;
		  case 2: 
			lightSettings = 0;
		    break;
		  default: 
		}
		printInfo();
	}
	
	public void switchRender(){
		switch (renderSettings) {
		  case 0: 
			renderSettings = 1;
		    break;
		  case 1: 
			//this.renderSettings = 2;
			this.renderSettings = 0;
		    break;
		  case 2: 
			renderSettings = 0;
		    break;
		  default: 
		}
		printInfo();
	}
	
	public void printInfo(){
		System.out.print("Lightning is done by :");
		if (this.lightSettings == 0) System.out.println("direct light");
		if (this.lightSettings == 1) System.out.println("point light");
		if (this.lightSettings == 2) System.out.println("spot light");
		System.out.print("Rendering is done by :");
		if (this.renderSettings == 0) System.out.println("brute force");
		if (this.renderSettings == 1) System.out.println("display lists");
		if (this.renderSettings == 2) System.out.println("vertex arrays");
	}
	
	public void switchFreeze(){
		if (freeze){
			freeze = false;
			//notify();
		}
		else freeze = true;
	}
	
	public void addAngle(){
		if (freeze)return;
		angle = angle + 0.5;
		if (angle == 360) angle = 0;		
	}
	
	public void renderLoop(){
		while(true){
			try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			if(freeze){
				//try {
					//wait();
				//} catch (InterruptedException e) {
					//e.printStackTrace();
				//}
			}else{
				view.display();
				addAngle();
			}						
		}
	}
}
